package com.uplooking.controller;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import com.uplooking.constant.AdminConstants;
import com.uplooking.service.AdminService;

@RestController
public class AdminController {

	@Autowired
	private AdminService adminService;
	
	@GetMapping(value="/admin/user/list/{page}/{size}/{role}/{status}")
	public Object userList(@PathVariable(name="page")int page,
			@PathVariable(name="size")int size,
			@PathVariable(name="role")String role,
			@PathVariable(name="status")int status) {
		Map<String, Object> cond = new HashMap<String, Object>();
		if(!"0".equals(role))cond.put(AdminConstants.CondRole, role);
		if(status!=0)cond.put(AdminConstants.CondStatus, status);
		return adminService.getUserList(cond, page, size);
	}
	
	@GetMapping(value="/admin/role/list")
	public Object roleList() {
		return adminService.getRoleList();
	}
	
	@GetMapping(value="/admin/status/list")
	public Object statusList() {
		return adminService.getStatusList();
	}
	
	@GetMapping(value="/admin/check/shop/{username}")
	public Object checkShop(@PathVariable(name="username")String username) {
		return adminService.checkShop(username);
	}
}
